home *** CD-ROM | disk | FTP | other *** search
- Path: spiff.cc.iastate.edu!graphix
- From: graphix@iastate.edu (Kent A Vander Velden)
- Newsgroups: comp.lang.c++
- Subject: Derivation and calling virtual functions
- Date: 28 Mar 96 17:04:49 GMT
- Organization: Iowa State University, Ames, Iowa
- Message-ID: <graphix.828032689@spiff.cc.iastate.edu>
- NNTP-Posting-Host: spiff.cc.iastate.edu
-
- Say we have the following:
-
- class Base {
- public:
- virtual void func() { // some stuff }
- virtual void write() { func(); };
- };
-
- class Derived : public Base {
- public:
- void func() { // some stuff }
- write(); { Base::func(); }
- };
-
- Derived inst;
-
- Now, when I call inst.write() it in turn calls Bass::write() which in
- turn calls Base::func(). Is there a way to instead have it call
- Derived::func() if the instance is of type Derived? I hoped the
- virtual keyword would help in this case.
-
- Thanks.
-
- --
- Kent Vander Velden
- graphix@iastate.edu
-
-